package main

import "fmt"
import "strings"
import "jvmgo/ch02/classpath"
func main()  {
	cmd := parseCmd()
	if cmd.versionFlag {
		fmt.Println("version ch01");
	} else if cmd.helpFlag || cmd.class == "" {
		printUsage()
	} else {
		startJVM(cmd)
	}
} 

func startJVM(cmd *Cmd){
	cp := classpath.Parse(cmd.XjreOption,cmd.cpOption);
	fmt.Printf("classpath:%v class:%v arge:%v \n",cp,cmd.class,cmd.args);
	className := strings.Replace(cmd.class,".","/",-1)
	classData ,_,err := cp.ReadClass(className)
	if err != nil {
		fmt.Printf("Could not find or load main class %s \n",cmd.class)
		return
	}
	fmt.Printf("class data: %v \n ",classData)
}